isRunning = false;
if(self.parent.up!=null) self.parent.up.isRunning = false;
if(self.parent.down!=null) self.parent.down.isRunning = false;

function changeQty(index)
{
  var qty=eval("frm.orderqty" + index);
  var objbaseqty=eval("frm.baseqty"+index);
	var objinitfactor=eval("frm.initfactor"+index);
	objbaseqty.value=numberRound(""+Number(qty.value)*Number(objinitfactor.value),'<%=JspHelper.filterNull(session.getAttribute("qtyformat"))%>');

  if(!checkQty(qty,index))
  { 
    qty.value = qty.tempvalue;
    return;
  }
  qty.tempvalue = qty.value;
  calculateLinePrice(index,"orderqty");
	if(!sumOne(index)) return;
	if(!isEmpty(index)) 
	if(!sumAll()) return;
  formatNumberForOrder(index);
}
function changeUnitPrice(index)
{
  var unitprice=eval("frm.unitprice" + index);
  if(!checkUnitPrice(unitprice))
  {
    unitprice.value = unitprice.tempvalue;
    return;
  }  
  unitprice.tempvalue = unitprice.value;
  calculateLinePrice(index,"unitprice");
	if(!sumOne(index)) return;
	if(!isEmpty(index)) 
	if(!sumAll()) return;
  formatNumberForOrder(index);
}
function changeDiscount(index)
{
  var discount=eval("frm.discount" + index);
  if(!checkDiscount(discount))
  {
    discount.value = discount.tempvalue;
    return;
  }  
  discount.tempvalue = discount.value;
  calculateLinePrice(index,"discount");
    if(!sumOne(index)) return;
    if(!isEmpty(index))
	if(!sumAll()) return;
  formatNumberForOrder(index);
}
function changeDiscountAmt(index)
{
  var discountamt=eval("frm.discountamt" + index);
  var unitprice=eval("frm.unitprice" + index);  
  if(!checkDiscountAmt(discountamt,unitprice))
  {
    discountamt.value = discountamt.tempvalue;
    return;
  }  
  discountamt.tempvalue = discountamt.value;
  calculateLinePrice(index,"discountamt");
	if(!sumOne(index)) return;
	if(!isEmpty(index)) 
	if(!sumAll()) return;
  formatNumberForOrder(index);
}
function changeTotalDiscount()
{
  if(!checkTotalDiscount())
  {
    frm.totaldiscount.value = frm.totaldiscount.tempvalue;
    return;
  }  
  frm.totaldiscount.tempvalue = frm.totaldiscount.value;
  if(!sumAll("totaldiscount"))return;  
  formatTotalNumberForOrder();
}
function changeTotalDiscountAmt()
{
  if(!checkTotalDiscountAmt())
  {
    frm.totaldiscountamt.value = frm.totaldiscountamt.tempvalue;
    return;
  }  
  frm.totaldiscountamt.tempvalue = frm.totaldiscountamt.value;
  if(!sumAll("totaldiscountamt"))return;  
  formatTotalNumberForOrder();
}
function checkQty(qty,index)
{
  var flag = true;
  var buyerfactor = eval("frm.buyerfactor" + index);  
  if(isEmpty(qty.value))
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_OrderQty",false)) %>");
    flag = false;
  }  
  if(flag && !isNumberic(qty.value))
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_OrderQty",false)) %>");    
    flag = false;
  }
  if(flag && Number(qty.value) <= 0)
  {
    alert(replaceString("<%= message.getMessageDesc("VALUE_MUST_MORETHAN") %>","%s",'<%= label.getLabelName("L_OrderQty",false) %>',"0"));    
    flag = false;
  }
  if(flag && numberRound(qty.value*buyerfactor.value,"<%=JspHelper.filterNull( qtyformat )%>") <= 0 )
  {
    alert("<%= message.getMessageDesc("LITTLE_THAN_BUYER_UNIT_QTY")  %>");
    flag = false;
  }  
  if(flag)
  {
      qty.style.color = "";
  }else{
    document.body.focus();
    qty.select();
    qty.focus();
  }
  //checkNumber(frm);	  
  return flag;
}

function checkUnitPrice(price)
{
  var flag = true;
  if(!isNumberic(price.value))
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_Price",false)) %>");
    flag = false;
  }
  if(flag && Number(price.value) < 0)
  {
    alert(replaceString("<%= message.getMessageDesc("VALUE_MUST_MORETHAN") %>","%s",'<%= label.getLabelName("L_Price",false) %>',"0"));    
    flag = false;
  }
  if(!flag)
  {
    document.body.focus();
    price.select();
    price.focus();  
  }
  //checkNumber(frm);	  
  return flag;
}
function checkDiscount(discount)
{
  var flag = true;
  if(!isNumberic(discount.value))
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_DiscountRate",false)) %>");    
    flag = false;
  }
  if(flag && discount.value - 100 > 0)
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_MORETHAN",label.getLabelName("L_DiscountRate",false),"100%") %>");
    flag = false;
  }      
  if(flag && discount.value - 100 == 0)
  {
    if(!confirm("<%= message.getMessageDesc("ZERO_VALUE_CONTINUE",label.getLabelName("L_NetPrice",false)) %>"))
      flag = false;
  }      
  if(!flag)
  {
    document.body.focus();
    discount.select();
    discount.focus();  
  }
  //checkNumber(frm);	  
  return flag;
}
function checkDiscountAmt(discountamt,unitprice)
{
  var flag = true;
  if(!isNumberic(discountamt.value))
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_Discount",false)) %>");
    flag = false;
  }
  if(flag && discountamt.value - unitprice.value > 0)
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_MORETHAN",label.getLabelName("L_Discount",false),label.getLabelName("L_Price",false)) %>");
    flag = false;
  }    
  if(flag && discountamt.value - unitprice.value == 0)
  {
    if(!confirm("<%= message.getMessageDesc("ZERO_VALUE_CONTINUE",label.getLabelName("L_NetPrice",false)) %>"))
      flag = false;
  }    
  if(!flag)
  {
    document.body.focus();
    discountamt.select();
    discountamt.focus();  
  }
  //checkNumber(frm);	  
  return flag;
}
function checkTotalDiscount()
{
  var flag = true;
  if(!isNumberic(frm.totaldiscount.value))
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_DiscountRate",false)) %>");
    var flag = false;
  }
  if(flag && frm.totaldiscount.value - 100 > 0)
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_MORETHAN",label.getLabelName("L_DiscountRate",false),"100%") %>");
    var flag = false;
  }      
  if(!flag)
  {
    document.body.focus();
    frm.totaldiscount.select();
    frm.totaldiscount.focus();  
  }
  //checkNumber(frm);	  
  return flag;
}

function checkTotalDiscountAmt()
{
  var flag = true;
  if(!isNumberic(frm.totaldiscountamt.value))
  {
    alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_Discount",false)) %>");    
    flag = false;
  }
  if(flag && frm.totaldiscountamt.value - frm.subtotalamt.value > 0)
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_MORETHAN",label.getLabelName("L_DiscountAmt",false),label.getLabelName("L_Subtotal",false)) %>");
    flag = false;
  }
  if(!flag)
  {
    document.body.focus();
    frm.totaldiscountamt.select();
    frm.totaldiscountamt.focus();
  }
  //checkNumber(frm);
  return flag;
}

function calculateLinePrice(index,opt)
{
  var unitprice = eval("frm.unitprice" + index);
  var discount = eval("frm.discount" + index);
  var discountamt = eval("frm.discountamt" + index);
  var linenetprice = eval("frm.linenetprice" + index);
  var locallinenetprice = eval("frm.locallinenetprice" + index);
  var pretaxprice = eval("frm.pretaxprice" + index);
  var taxrate = eval("frm.taxrate" + index);

  var objzctrate=eval("frm.zctrate");

  if(opt == "discount"){
    discountamt.value = "";
    discountamt.tempvalue = discountamt.value;
    linenetprice.value = numberRound(numberToString(unitprice.value*(1-discount.value/100)),linenetprice.dataFormat);
  }else if(opt == "discountamt"){
    discount.value = "";
    discount.tempvalue = discount.value;
    linenetprice.value = numberRound(numberToString(unitprice.value - discountamt.value),linenetprice.dataFormat);
  }else if(opt == "unitprice"){
    discount.value = "";
    discount.tempvalue = discount.value;
    discountamt.value = "";
    discountamt.tempvalue = discount.value;
    linenetprice.value = unitprice.value;
  }
  locallinenetprice.value= numberRound(numberToString(linenetprice.value*Number(objzctrate.value)),locallinenetprice.dataFormat);
  pretaxprice.value = numberRound(""+ (locallinenetprice.value/(1 + Number(taxrate.value))),'<%=JspHelper.filterNull(session.getAttribute("priceformat"))%>') ;
  return true;
}

function sumOne(index)
{
  //checkNumber(frm);
  var unitprice = eval("frm.unitprice" + index);
  var discount = eval("frm.discount" + index);
  var discountamt = eval("frm.discountamt" + index);
  var linenetprice = eval("frm.linenetprice" + index);
  var orderqty = eval("frm.orderqty" + index);
  var amount = eval("frm.amount" + index);
  var taxrate = eval("frm.taxrate" + index);
  var pretaxprice = eval("frm.pretaxprice" + index);
  var taxamount = eval("frm.taxamount" + index);
  var pretaxamount = eval("frm.pretaxamount" + index);
  //var baseqty = eval("frm.baseqty" + index);
  var umcode = eval("frm.umcode" + index);
  //amount.value = orderqty.value*linenetprice.value;
   amount.value= numberToString(""+numberRound(Number(orderqty.value)*numberRound(Number(linenetprice.value),'<%=JspHelper.filterNull(session.getAttribute("priceformat"))%>'),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));
  /* modify by kent 2004-7-30 10:49
  **************************************************************
  */
  var zctamount=eval("frm.zctamount"+index);
  var objzctrate=eval("frm.zctrate");

  //alert("orderqty=" + orderqty.value + ":  linenetprice="+linenetprice.value +":  objzctrate="+ objzctrate.value + ": pretaxprice="+pretaxprice.value);
 // zctamount.value=numberToString(numberRound(""+ numberRound(""+ orderqty.value*numberRound(Number(linenetprice.value),'<%=JspHelper.filterNull(session.getAttribute("priceformat"))%>'),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>')*Number(objzctrate.value),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));
   zctamount.value=numberRound((numberRound(Number(linenetprice.value)*Number(objzctrate.value),'<%=JspHelper.filterNull(session.getAttribute("priceformat"))%>'))*numberRound(Number(orderqty.value),'<%=JspHelper.filterNull(session.getAttribute("qtyformat"))%>'),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>');
  //pretaxamount.value =numberToString(numberRound(""+ ( Number(orderqty.value) * Number(pretaxprice.value) ),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));
  pretaxamount.value= numberToString(""+numberRound(Number(orderqty.value)*numberRound(Number(pretaxprice.value),'<%=JspHelper.filterNull(session.getAttribute("priceformat"))%>'),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));
  taxamount.value = numberToString(numberRound(""+(Number(zctamount.value)-Number(pretaxamount.value)),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));
//taxamount.value = numberToString(numberRound(""+(Number(zctamount.value)-Number(pretaxamount.value)),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));
  // taxamount.value = numberRound(""+Number(zctamount.value)*Number(taxrate.value)/(1+Number(taxrate.value)),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>
 // pretaxamount.value =Number(zctamount.value)-Number(taxamount.value)
 // alert("zctamount="+ zctamount.value + ":  taxamount" + taxamount.value +":  pretaxamount="+ pretaxamount.value);
  /***********    modify end  ***************/
  //baseqty.value = orderqty.value;
  //checkNumber(frm);
  
  return true;
}

function sumAll(val)
{
  var totala = 0;
  var totalt = 0;
  var zcttotal=0;
  with(frm)    
  {
    for(var i = 0;i < numrows.value;i++)
    {
      var oneamt = eval("amount" + i);
      var onetax = eval("taxamount" + i);
      var onezctamt=eval("zctamount"+i);
      totala += Number(oneamt.value);
      totalt += Number(onetax.value);
      zcttotal+=Number(onezctamt.value);
    }    
  }  
  var totalamount = eval("frm.totalamount");
  var totaltaxamt = eval("frm.totaltaxamount");
  var subtotalamt = eval("frm.subtotalamt");
  
  var zctsubtotalamt=eval("frm.zctsubtotalamt");
  var zcttotalamount = eval("frm.zcttotalamount");
  
 var objzctrate=eval("frm.zctrate");
  
  var totaldiscount = eval("frm.totaldiscount");
  var totaldiscountamt = eval("frm.totaldiscountamt");
  totaltaxamt.value = totalt;
  subtotalamt.value = totala;
  //zctsubtotalamt.value = zcttotal;
   zctsubtotalamt.value = totala*objzctrate.value; <!--edit by wangyoung-->
  
  if(val == "totaldiscount")
  {
    totaldiscountamt.value = "";
    //totalamount.value = subtotalamt.value*(1-totaldiscount.value/100);
      totalamount.value = numberToString(numberRound(subtotalamt.value*(1-totaldiscount.value/100),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>'));<!--edit by wangyoung-->
  }
  if(val == "totaldiscountamt")
  {
    totaldiscount.value = "";
    //totalamount.value = subtotalamt.value - totaldiscountamt.value;
      totalamount.value =  numberToString(numberRound(subtotalamt.value - totaldiscountamt.value,'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>')); <!--edit by wangyoung-->
  }
  if(isEmpty(val))
  {
    if(isEmpty(frm.totaldiscount.value))
      //frm.totalamount.value = frm.subtotalamt.value - frm.totaldiscountamt.value;
       frm.totalamount.value = numberToString(numberRound(frm.subtotalamt.value - frm.totaldiscountamt.value,'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>')); <!--edit by wangyoung-->
    else
      //frm.totalamount.value = frm.subtotalamt.value*(1 - frm.totaldiscount.value/100);
        frm.totalamount.value = numberToString(numberRound(frm.subtotalamt.value*(1 - frm.totaldiscount.value/100),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>')); <!--edit by wangyoung-->
  }
  //zcttotalamount.value=numberRound(""+Number(totalamount.value)*Number(objzctrate.value),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>');
    zcttotalamount.value=numberToString(numberRound(""+Number(totalamount.value)*Number(objzctrate.value),'<%=JspHelper.filterNull(session.getAttribute("amountformat"))%>')); <!--edit by wangyoung-->
  //checkNumber(frm);
  if(Number(totaldiscount.value) == 0 && Number(totaldiscountamt.value) == 0)
    frm.totaldiscountopt.value = "nodiscount";     
  else if(Number(totaldiscount.value) == 0)   
    frm.totaldiscountopt.value = "totaldiscountamt";     
  else   
    frm.totaldiscountopt.value = "totaldiscount";  
  return true;
}
function reSumAll()
{      
  var totalamt = 0;
  var ttaxamt = 0;
  
  var zcttotalamt=0;
  
  with(frm)
  {
    for(var index=0;index< <%=JspHelper.filterNull( orderDetails.size() )%>;index++)
    {
      if(<%=JspHelper.filterNull( orderDetails.size() )%> == 1 && detailids.checked == true)
        break;
      else if(detailids[index].checked == true)
        continue;
      totalamt += Number(detailids[index].amount);
      ttaxamt += Number(detailids[index].taxamount);
    }
    subtotalamt.value = totalamt;    
    totaldiscount.value = totaldiscount.realtotaldiscount;   
    totaldiscountamt.value = totaldiscountamt.realtotaldiscountamt;   
    if(subtotalamt.value - totaldiscountamt.value < 0 )
      totaldiscountamt.value = 0.0;
    if(totaldiscount.value)
      totalamount.value = subtotalamt.value - totaldiscountamt.value;
    else
      totalamount.value = subtotalamt.value*(1 - totaldiscount.value/100);
    totaltaxamount.value = ttaxamt;
  }
  return true;
}

function addDiscountValue()
{
  var tempvalue = "";
  if(frm.totaldiscount.value != "")
    tempvalue = frm.totaldiscount.value/100;
  if(tempvalue != "")
  {
    frm.totaldiscount.name = "temp";
    addElementToForm(frm,"totaldiscount",tempvalue,false,"hidden");
  }
  tempvalue = "";
  if(frm.discount.value != "")
    tempvalue = frm.discount.value/100;
  if(tempvalue != "")
  {
    frm.discount.name = "temp";
    addElementToForm(frm,"discount",tempvalue,false,"hidden");
  }
  for(var i = 0;i < frm.numrows.value;i++)
  {
    var discountx = eval("frm.discount" + i);
    tempvalue = "";
    if(discountx.value != "")
      tempvalue = discountx.value/100;
    if(tempvalue != "")
    {
      discountx.name = "temp";
      addElementToForm(frm,"discount" + i,tempvalue,false,"hidden");
    }
  }
}
function checkAllQty()
{
  for(var i = 0;i < frm.numrows.value;i++)
  {
    var orderqty = eval("frm.orderqty" + i);
    if(Number(orderqty.value) == 0 && orderqty.canzero!=0)
    {
      alert(replaceString("<%= message.getMessageDesc("VALUE_MUST_MORETHAN") %>","%s",'<%= label.getLabelName("L_OrderQty",false) %>',"0"));    
      document.body.focus();
      orderqty.select();
      orderqty.focus();
      return false;
    }
  }
  return true;
}
function getData(index,type)
{
  if(index == "") 
  {
    if(isEmpty(frm.<%=JspHelper.filterNull(itemcodename)%>.value))
    {
      distroy(); 
      return;
    }    
  }
  frm.unitprice.value = "";
  frm.itemid.value = "";
  frm.buyeritemid.value="";
  frm.shipfromitemid.value="";
  frm.selleritemid.value="";
  addDiscountValue();
  frm.actionname.value="getdata";
  frm.target="_self";
   setIsRunning(self);
  //alert(frmToString(frm));
  frm.submit();
}

function page_add(entertype)
{
	if(entertype='')
		entertype = frm.enteritemcodetypeopt.value;
  if(isEmpty(frm.buyeritemcode.value) && entertype=='1')
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Item",false)) %>");
    return false;
  }
  if(isEmpty(frm.selleritemcode.value) && entertype=='2')
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Item",false)) %>");
    return false;
  }
   if(isEmpty(frm.umcode.value))
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Item",false)) %>");
    frm.selleritemcode.value="";
    frm.buyeritemcode.value="";
    return false;
  }
  if(!checkQty(frm.orderqty,""))
    return false;
  if(Number(frm.orderqty.value) == 0)
  {
    alert(replaceString("<%= message.getMessageDesc("VALUE_MUST_MORETHAN") %>","%s",'<%= label.getLabelName("L_OrderQty",false) %>',"0"));    
    document.body.focus();
    frm.orderqty.select();
    frm.orderqty.focus();
    return false;
  }
  if(!sumOne(""))
    return false;
  frm.subtotalamt.value = Number(frm.subtotalamt.realsubtotalamt) + Number(frm.amount.value);     
  frm.totaldiscount.value = frm.totaldiscount.realtotaldiscount;   
  frm.totaldiscountamt.value = frm.totaldiscountamt.realtotaldiscountamt;   
  frm.totaltaxamount.value = Number(frm.totaltaxamount.realtotaltaxamount) + Number(frm.taxamount.value);   
  if(isEmpty(frm.totaldiscount.value))
    frm.totalamount.value = frm.subtotalamt.value - frm.totaldiscountamt.value;
  else
    frm.totalamount.value = frm.subtotalamt.value*(1 - frm.totaldiscount.value/100);

  //checkNumber(frm);
  addDiscountValue();
  frm.actionname.value="add";
  frm.target="_self";
  setIsRunning(self);
  //alert(frmToString(frm));
  frm.submit();
}
function page_delete()
{
  if(nullChecked(frm.detailids))
  {
		alert('<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>');
		return;
  }
  if(!reSumAll()) return;
  addDiscountValue();
  emptyToNull(frm);
  frm.actionname.value="delete";
  frm.target="_self";
  setIsRunning(self);;
  //alert(frmToString(frm));
  frm.submit();
}
function page_save(opt)
{

  if(!checkTotalDiscountAmt())
  {
    frm.totaldiscountamt.value = frm.totaldiscountamt.tempvalue;
    return;
  }
  frm.totaldiscountamt.tempvalue = frm.totaldiscountamt.value;
  formatTotalNumberForOrder();
	<%if(orderDetails.size()>0){%>
  if(!checkAllQty()) return false;
  if(!sumAll()) return false;
  addDiscountValue();
  emptyToNull(frm);
  frm.actionname.value="save";
  frm.target="_self";
  setIsRunning(self);;
  //alert(frmToString(frm));
  frm.submit();
   <%}%>
}
function page_calprice()
{
  frm.subtotalamt.value = frm.subtotalamt.realsubtotalamt;
  if(frm.totaldiscount.value)
    frm.totalamount.value = frm.subtotalamt.value - frm.totaldiscountamt.value;
  else
    frm.totalamount.value = frm.subtotalamt.value*(1 - frm.totaldiscount.value/100);
  addDiscountValue();
  //checkNumber(frm);
  frm.actionname.value="calcprice";
  frm.target="_self";
  setIsRunning(self);;
  //alert(frmToString(frm));
  frm.submit();
}
function formatNumberForOrder(index)
{
  var unitprice = eval("frm.unitprice" + index);
  var discount = eval("frm.discount" + index);
  var discountamt = eval("frm.discountamt" + index);
  var linenetprice = eval("frm.linenetprice" + index);
  var locallinenetprice = eval("frm.locallinenetprice" + index);
  var orderqty = eval("frm.orderqty" + index);
  var amount = eval("frm.amount" + index);
  var taxrate = eval("frm.taxrate" + index);
  var pretaxprice = eval("frm.pretaxprice" + index);
  var taxamount = eval("frm.taxamount" + index);
  var pretaxamount = eval("frm.pretaxamount" + index);
  //var baseqty = eval("frm.baseqty" + index);
  unitprice.value = numberRound(numberToString(unitprice.value),unitprice.dataFormat);
  discount.value = numberRound(numberToString(discount.value),discount.dataFormat);
  discountamt.value = numberRound(numberToString(discountamt.value),discountamt.dataFormat);
  linenetprice.value = numberRound(numberToString(linenetprice.value),linenetprice.dataFormat);
  locallinenetprice.value = numberRound(numberToString(locallinenetprice.value),locallinenetprice.dataFormat);
  orderqty.value = numberRound(numberToString(orderqty.value),orderqty.dataFormat);
  amount.value = numberRound(numberToString(amount.value),amount.dataFormat);
  taxrate.value = numberRound(numberToString(taxrate.value),taxrate.dataFormat);
  pretaxprice.value = numberRound(numberToString(pretaxprice.value),pretaxprice.dataFormat);
  taxamount.value = numberRound(numberToString(taxamount.value),taxamount.dataFormat);
  if(taxamount.value == "NaN") taxamount.value = "";
  pretaxamount.value = numberRound(numberToString(pretaxamount.value),pretaxamount.dataFormat);
  //baseqty.value = numberRound(numberToString(baseqty.value),baseqty.dataFormat);
  formatTotalNumberForOrder();
}
function formatTotalNumberForOrder()
{
  var totalamount = eval("frm.totalamount");
  var totaltaxamt = eval("frm.totaltaxamount");
  var subtotalamt = eval("frm.subtotalamt");
  var totaldiscount = eval("frm.totaldiscount");
  var totaldiscountamt = eval("frm.totaldiscountamt");
  var zctsubtotalamt = eval("frm.zctsubtotalamt");
  var zcttotalamount = eval("frm.zcttotalamount");

  totalamount.value = numberRound(numberToString(totalamount.value),totalamount.dataFormat);
  totaltaxamt.value = numberRound(numberToString(totaltaxamt.value),totaltaxamt.dataFormat);
  subtotalamt.value = numberRound(numberToString(subtotalamt.value),subtotalamt.dataFormat);
  totaldiscount.value = numberRound(numberToString(totaldiscount.value),totaldiscount.dataFormat);
  totaldiscountamt.value = numberRound(numberToString(totaldiscountamt.value),totaldiscountamt.dataFormat);
  zctsubtotalamt.value = numberRound(numberToString(zctsubtotalamt.value),zctsubtotalamt.dataFormat);
  zcttotalamount.value = numberRound(numberToString(zcttotalamount.value),zcttotalamount.dataFormat);
}
function distroy()
{
  frm.itemid.value = "";
  frm.itemcode.value="";
  frm.itemname.value="";
  frm.<%=JspHelper.filterNull(itemcodename)%>.value="";
  frm.buyeritemid.value="";
  frm.selleritemid.value="";
  frm.unitprice.value="";
  frm.listprice.value="";
  frm.taxrate.value="";
  frm.taxamount.value="";
  frm.orderqty.value="";
  frm.discount.value="";
  frm.discountamt.value="";
  frm.amount.value="";
  frm.umname.value="";
  frm.zctrate.value="";
  frm.locallinenetprice.value="";
  frm.zctamount.value="";
}
